package com.swg.seckill.controller;

import com.swg.seckill.pojo.User;
import com.swg.seckill.service.IGoodsService;
import com.swg.seckill.utils.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Acer
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private IGoodsService iGoodsService;
    
    @Autowired
    @Qualifier("myRedisTemplate")
    private RedisTemplate redisTemplate;


    @RequestMapping("/toList")
    public String toList(User user){
        return user.toString();
    }

    @RequestMapping("/getAllGoods")
    public List<GoodsVo>  goodsList(){
        List<GoodsVo> allGoods = iGoodsService.getGoods();
        return allGoods;
    }

    @RequestMapping("/getGoods/{id}")
    public GoodsVo listGood(User user,@PathVariable("id")Long id){
        System.out.println(user.toString());
        return iGoodsService.listGoods(id);
    }
}
